function add() {
    var name=$('#course-name').val();
    var describe=$('#course-text').val();
    var startTime=$('#course-start-input').val();
    var endTime=$('#course-end-input').val();
    $.ajax({
        cache : true,
        type : "POST",
        url : "/course/create",
        data : {
            name:name,
            describe:describe,
            startTime:startTime,
            endTime:endTime,
        },
        async : false,
        dataType: 'JSON',
        error : function(request) {
            alert("Connection error");
        },
        success : function(r) {
            if (r.code == 0) {
                parent.layer.msg(r.msg);
                parent.location.reload();
                var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                parent.layer.close(index);

            } else {
                parent.layer.msg(r.msg);
            }
        }
    });
}

function join() {
    var id=$('#course-code').val();
    $.ajax({
        cache : true,
        type : "POST",
        url : "/course/join",
        data : {
            id:id,
        },
        async : false,
        dataType: 'JSON',
        error : function(request) {
            alert("Connection error");
        },
        success : function(r) {
            if (r.id == 0) {
                parent.layer.msg(r.msg);
                parent.location.reload();
                var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                parent.layer.close(index);

            } else {
                parent.layer.msg(r.msg);
            }
        }
    });
}